package org.ichihamigua.video.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.ichihamigua.common.framework.entity.Result;
import org.ichihamigua.common.video.entity.VideoBulletEntity;
import org.ichihamigua.common.video.entity.VideoEntity;
import org.ichihamigua.common.video.entity.vo.VideoVo;

import java.util.List;

/**
 * @author rainkyzhong
 * @date 2023/10/30 14:44
 */
@Mapper
public interface VideoMapper extends BaseMapper<VideoEntity> {

    @Select(
            """
            SELECT * FROM ic_video
            WHERE id IN (
                SELECT video_id AS id
                FROM ic_video_category_bind
                WHERE category_id = #{categoryId}
            )
            LIMIT #{offset}, #{pageNum}
            """
    )
    List<VideoEntity> getVideoList(
            @Param("categoryId") long categoryId,
            @Param("offset") int offset,
            @Param("pageNum") int pageNum
    );
}
